package com.example.film.controller;

import com.example.film.entity.FillingCompany;
import com.example.film.service.FillingCompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "备案公司信息管理接口")
@CrossOrigin
@RestController
@RequestMapping("filling/v1")
public class FillingCompanyController {

    @Autowired
    private FillingCompanyService fillingCompanyService;

    @ApiOperation("备案公司信息")
    @GetMapping("/company")
    public List<FillingCompany> getFillingCompany(){
        return fillingCompanyService.findFillingCompany();
    }

    @ApiOperation("分页查询备案公司信息")
    @GetMapping("/companyInfo")
    public List<FillingCompany> getFillingCompanyInfo(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return fillingCompanyService.findFillingCompanyInfo(pageNum,pageSize);
    }

    @ApiOperation("根据影片类别分页显示备案公司信息")
    @GetMapping("/type")
    public List<FillingCompany> getFillingCompanyByType(@RequestParam String type,@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return fillingCompanyService.findFillingCompanyByType(type, pageNum, pageSize);
    }

    @ApiOperation("根据年份分页显示备案公司信息")
    @GetMapping("/year")
    public List<FillingCompany> getFillingCompanyByType(@RequestParam Integer year,@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return fillingCompanyService.findFillingCompanyByYear(year, pageNum, pageSize);
    }

    @ApiOperation("根据条件分页显示备案公司信息")
    @GetMapping("/month")
    public List<FillingCompany> getFillingCompanyByCondition(@RequestParam Integer year,@RequestParam Integer month,@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return fillingCompanyService.findFillingCompanyByCondition(year, month, pageNum, pageSize);
    }
}
